package com.gitee.ice1938.adcode.fun;

import java.util.Date;
import java.util.Iterator;

import org.apache.commons.csv.CSVRecord;

public class DataRecord {
	private Boolean addflag;
	private String adCode;
	private String adName;
	private Date revokeTime;
	
	public static DataRecord  form(CSVRecord record) {
		Iterator<String> iterator = record.iterator();
		DataRecord item = new DataRecord();
		item.setAddflag(true);
		int i = 0;
		while (iterator.hasNext()) {
			if (i == 0) {
				item.setAdCode(iterator.next());
			}
			if (i == 1) {
				item.setAdName(iterator.next());
			}
			i++;
		}
		return item;
	}
	public static DataRecord  formChange(CSVRecord record) {
		Iterator<String> iterator = record.iterator();
		DataRecord item = new DataRecord();
		int i = 0;
		while (iterator.hasNext()) {
			if (i == 0) {
				String s = iterator.next();
				item.setAddflag(!"-".equals(s));
			}
			if (i == 1) {
				item.setAdCode(iterator.next());
			}
			if (i == 2) {
				item.setAdName(iterator.next());
			}
			if (i == 3) {
				//TODO 
				//item.setRevokeTime(iterator.next());
			}
			i++;
		}
		return item;
	}
	
	public Boolean getAddflag() {
		return addflag;
	}
	public void setAddflag(Boolean addflag) {
		this.addflag = addflag;
	}
	public String getAdCode() {
		return adCode;
	}
	public void setAdCode(String adCode) {
		this.adCode = adCode;
	}
	public String getAdName() {
		return adName;
	}
	public void setAdName(String adName) {
		this.adName = adName;
	}
	public Date getRevokeTime() {
		return revokeTime;
	}
	public void setRevokeTime(Date revokeTime) {
		this.revokeTime = revokeTime;
	}
	@Override
	public String toString() {
		return "DataRecord [addflag=" + addflag + ", adCode=" + adCode + ", adName=" + adName + ", revokeTime="
				+ revokeTime + "]";
	}
	
}
